﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DigitalRune.Windows.Docking;
using CalemShop.Classes;

namespace CalemShop.Forms
{
    public partial class FrmBaseDock : DockableForm
    {
        protected FrmCalemShop frmParent = null;
        protected bool isDisplay = false;

        public FrmBaseDock()
        {
            InitializeComponent();
            InitResource();
            SetFontAndLayout();
        }


        public FrmBaseDock(FrmCalemShop p)
            : base()
        {
            CheckForIllegalCrossThreadCalls = false;
            frmParent = p;
            InitializeComponent();
            InitResource();
            SetFontAndLayout();
            this.Disposed += new EventHandler(FrmBaseDock_Disposed);
        }

        protected virtual void InitResource()
        {
        }

        private void FrmBaseDock_Disposed(object sender, EventArgs e)
        {
            isDisplay = false;
            ReleaseResource();
        }

        protected virtual void ReleaseResource()
        {
        }

        protected FrmCalemShop CalemShop
        {
            get { return this.frmParent; }
        }

        public void Display(DigitalRune.Windows.Docking.DockState state)
        {
            if (!isDisplay)
            {
                isDisplay = true;
                DockPanel docking = frmParent.dockPanel;
                this.Show(docking, state);
            }
            else
            {
                this.Activate();
            }
        }

        protected virtual void SetFontAndLayout()
        {
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }

        public virtual void FormActived()
        {

        }
    }
}
